package com.taptech.doufu.ui.adapter;

import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.squareup.picasso.Picasso;
import com.taptech.doufu.R;
import com.taptech.doufu.app.WeMediaApplication;
import com.taptech.doufu.bean.cp.ItemCpRankBean;

import java.util.List;

/**
 * author zhangyongcun
 * 16/9/29
 * cp 排行适配器
 */
public class ItemCpRankAdapter extends RecyclerView.Adapter<ItemCpRankAdapter.ViewHolder>{

    List<ItemCpRankBean.DataBean.ItemsBean> itemCpRankBeanList;

    public ItemCpRankAdapter(List<ItemCpRankBean.DataBean.ItemsBean> itemCpRankBeanList) {
        this.itemCpRankBeanList = itemCpRankBeanList;
    }

    @Override
    public ItemCpRankAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.cp_rank_list_item_layout,parent, false);
        return new ItemCpRankAdapter.ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ItemCpRankAdapter.ViewHolder holder, int position) {
        ItemCpRankBean.DataBean.ItemsBean itemCpRankBean = itemCpRankBeanList.get(position);
        Picasso.with(WeMediaApplication.getInstance()).load(itemCpRankBean.getIcon()).into(holder.imageView);
    }

    @Override
    public int getItemCount() {
        return itemCpRankBeanList.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder {
        ImageView imageView;
        public ViewHolder(View itemView) {
            super(itemView);
            imageView = (ImageView) itemView.findViewById(R.id.item_cp_rank_img);
        }
    }
}
